{template '_header'}

<div class="page-heading"> <h2>分销商统计 <small>总数: <span class='text-danger'>{$total}</span></small></h2> </div>
<form action="./index.php" method="get" class="form-horizontal" role="form" id="form1">
    <input type="hidden" name="c" value="site" />
    <input type="hidden" name="a" value="entry" />
    <input type="hidden" name="m" value="ewei_shopv2" />
    <input type="hidden" name="do" value="web" />
    <input type="hidden" name="r" value="commission.statistics.agent" />

    <div class="page-toolbar row m-b-sm m-t-sm">

        <div class="col-sm-5">
            {php echo tpl_daterange('ordertime', array('sm'=>true, 'placeholder'=>'下单时间'),true);}
        </div>

        <!--div class="col-sm-4">

            <div class="input-group-btn">
                <button class="btn btn-default btn-sm"  type="button" data-toggle='refresh'><i class='fa fa-refresh'></i></button>
                {ifp 'commission.agent.edit'}
                <div class="btn-group btn-group-sm">
                    <button data-toggle="dropdown" class="btn btn-default">黑名单 <span class="caret"></span>
                    </button>
                    <ul class="dropdown-menu">
                        <li><a class='btn' data-toggle='batch' data-href="{php echo webUrl('commission/agent/agentblack',array('agentblack'=>1))}" data-confirm='确认要设置黑名单?'>设置黑名单</a></li>
                        <li><a class='btn'  data-toggle='batch' data-href="{php echo webUrl('commission/agent/agentblack',array('agentblack'=>0))}" data-confirm='确认要取消黑名单?'>取消黑名单</a></li>
                    </ul>
                </div>

                <div class="btn-group btn-group-sm">
                    <button data-toggle="dropdown" class="btn btn-default">审核 <span class="caret"></span>
                    </button>
                    <ul class="dropdown-menu">
                        <li><a class='btn'  data-toggle='batch' data-href="{php echo webUrl('commission/agent/check',array('status'=>1))}"  data-confirm='确认要审核通过?'>审核通过</a></li>
                        <li><a class='btn'  data-toggle='batch' data-href="{php echo webUrl('commission/agent/check',array('status'=>0))}" data-confirm='确认要取消审核?'>取消审核</a></li>
                    </ul>
                </div>

                {/if}


                {ifp 'commission.agent.delete'}
                <button class="btn btn-default btn-sm" type="button" data-toggle='batch-remove' data-confirm="确认要删除?" data-href="{php echo webUrl('commission/agent/delete')}"><i class='fa fa-trash'></i> 删除</button>
                {/if}
            </div>
        </div-->


        <div class="col-sm-7 pull-right">

            <select name='status' class='form-control  input-sm select-md' style="width:100px;"  >
                <option value=''>状态</option>
                <option value='0' {if $_GPC['status']=='0'}selected{/if}>未审核</option>
                <option value='1' {if $_GPC['status']=='1'}selected{/if}>已审核</option>
            </select>
            <select name='searchfield'  class='form-control  input-sm select-sm'   style="width:100px;"  >

                <option value='member' {if $_GPC['searchfield']=='member'}selected{/if}>分销商</option>
                <option value='parent' {if $_GPC['searchfield']=='parent'}selected{/if}>推荐人</option>

            </select>
            <div class="input-group">
                <input type="text" class="form-control input-sm"  name="keyword" value="{$_GPC['keyword']}" placeholder="昵称/姓名/手机号"/>
				 <span class="input-group-btn">
                                
                                        <button class="btn btn-sm btn-primary" type="submit"> 搜索</button>
										<button class="btn btn-sm btn-default" type="button" onclick="$('#moresearch').toggle()"> 其他 <i class="fa fa-angle-down"></i></button> 
                                                                                	    {ifp 'commission.agent.export'}
                        <button type="submit" name="export" value="1" class="btn btn-success btn-sm">导出</button>
                        {/if}
				</span>
            </div>

        </div>
    </div>

    <div class="page-toolbar row" {if $_GPC['followed']=='' && $_GPC['level']=='' && $_GPC['groupid']=='' && $_GPC['isblack']=='' && $_GPC['time']['start']==''  && $_GPC['time']['end']=='' }style='display:none;'{/if} id='moresearch' >


    <div class="col-sm-12">

        <select name='followed' class='form-control  input-sm select-md' style="width:140px">
            <option value=''>关注</option>
            <option value='0' {if $_GPC['followed']=='0'}selected{/if}>未关注</option>
            <option value='1' {if $_GPC['followed']=='1'}selected{/if}>已关注</option>
            <option value='2' {if $_GPC['followed']=='2'}selected{/if}>取消关注</option>
        </select>


        <select name='agentlevel' class='form-control  input-sm select-md' style="width:140px;"  >
            <option value=''>等级</option>
            {loop $agentlevels $level}
            <option value='{$level['id']}' {if $_GPC['agentlevel']==$level['id']}selected{/if}>{$level['levelname']}</option>
            {/loop}
        </select>



        <select name='isagentblack'  class='form-control  input-sm select-md'   style="width:140px;"  >
            <option value=''>黑名单</option>
            <option value='0' {if $_GPC['isagentblack']=='0'}selected{/if}>否</option>
            <option value='1' {if $_GPC['isagentblack']=='1'}selected{/if}>是</option>
        </select>


        {php echo tpl_daterange('time', array('sm'=>true, 'placeholder'=>'成为分销商时间'),true);}




    </div>


    </div>
</form>
{if count($list)>0}

<table class="table table-hover table-responsive">
    <thead class="navbar-inner" >
    <tr>
        <th style="width:25px;"><input type='checkbox' /></th>

        <th style='width:110px;'>粉丝</th>
        <th style='width:110px;'>姓名<br/>手机号码<br/>等级</th>
        <th style='width:110px;'>分销金额<br/>分销订单数量</th>
        <th style='width:80px;'>累计佣金<br/>打款佣金</th>
        <th style='width:95px;'>下级累计佣金<br/>下级分销商</th>
        <th style='width:135px;'>注册时间<br/>审核时间</th>
        <th style='width:70px;'>状态<br/>关注</th>
        <th style='width:70px;'>操作</th>
    </tr>
    </thead>
    <tbody>
    {loop $list $row}
    <tr rel="pop" data-title="ID: {$row['id']} " data-content="推荐人 <br/> {if empty($row['agentid'])}
				  {if $row['isagent']==1}
				      <label class='label label-primary'>总店</label>
				      {else}
				       <label class='label label-default'>暂无</label>
				      {/if}
				{else}
				
                    	{if !empty($row['parentavatar'])}
                         <img src='{$row['parentavatar']}' style='width:20px;height:20px;padding1px;border:1px solid #ccc' />
                       {/if}
                       [{$row['agentid']}]{if empty($row['parentname'])}未更新{else}{$row['parentname']}{/if}
					   {/if}">

        <td>
            <input type='checkbox'   value="{$row['id']}"/>
        </td>

        <td >
            <span data-toggle='tooltip' title='{$row['nickname']}'>
            {if !empty($row['avatar'])}
            <img src='{$row['avatar']}' style='width:30px;height:30px;padding1px;border:1px solid #ccc' />
            {/if}
            {if empty($row['nickname'])}未更新{else}{$row['nickname']}{/if}
            </span>
        </td>

        <td>{$row['realname']} <br/> {$row['mobile']} <br/> {if empty($row['levelname'])} {php echo empty($this->set['levelname'])?'普通等级':$this->set['levelname']}{else}{$row['levelname']}{/if}</td>



        <td>{$row['ordermoney']}
            <br/>
            {$row['level_ordercount']}
            {if $row['level_ordercount']>0}
            <a data-toggle='popover' data-placement='bottom' data-html="true" data-content='一级：{$row['level1_ordercount']} 个订单<br/> 二级：{$row['level2_ordercount']} 个订单<br/>三级：{$row['level3_ordercount']} 个订单'>
            <i class='fa fa-question-circle'></i>
            </a>
            {/if}
        </td>

        <td>{$row['commission_total']}<br/>{$row['commission_pay']}</td>

        <td >
            {$row['level_commission_total']}
            <br/>
            {$row['levelcount']}
            {if $row['levelcount']>0}
            <a data-toggle='popover' data-placement='bottom' data-html="true" data-content='{if $level>=1 && $row['level1']>0}一级：{$row['level1']} 人{/if}{if $level>=2  && $row['level2']>0}<br/> 二级：{$row['level2']} 人{/if}{if $level>=3  && $row['level3']>0}<br/>三级：{$row['level3']} 人{/if}'>
            <i class='fa fa-question-circle'></i>
            </a>
            {/if}
        </td>
        <td>{php echo date('Y-m-d H:i',$row['createtime'])}
            <br/>
            {if !empty($row['agenttime'])}
            {php echo date('Y-m-d H:i',$row['agenttime'])}
            {else}
            -
            {/if}
        </td>

        <td>
            <span class='label {if $row['status']==1}label-success{else}label-default{/if}'>
            {if $row['status']==1}已审核{else}未审核{/if}</span>
            <br/>


            <span class='label {if $row['agentblack']==0}label-success{else}label-default{/if}'>
            {if $row['agentblack']==1}黑名单{else}正常{/if}</span>
            <br/>

            {if empty($row['followed'])}
            {if empty($row['uid'])}
            <label class='label label-default'>未关注</label>
            {else}
            <label class='label label-warning'>取消关注</label>
            {/if}
            {else}
            <label class='label label-primary'>已关注</label>
            {/if}
        </td>

        <td  style="overflow:visible;">

            <div class="btn-group btn-group-sm">
                <a class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false" href="javascript:;">操作 <span class="caret"></span></a>
                <ul class="dropdown-menu dropdown-menu-left">



                    {ifp 'member.list.view'}<li><a href="{php echo webUrl('member/list/detail',array('id' => $row['id']));}" title='会员信息' target='_blank'><i class='fa fa-user'></i> 会员信息</a></li>	{/if}
                    {ifp 'order.list'}<li><a  href="{php echo webUrl('order/list',array('agentid' => $row['id']));}" title='推广订单'  target='_blank'><i class='fa fa-list'></i> 推广订单</a></li>{/if}
                    {ifp 'commission.agent.user'}<li><a  href="{php echo webUrl('commission/agent/user',array('id' => $row['id']));}"  title='推广下线'  target='_blank'><i class='fa fa-users'></i> 推广下线</a></li>{/if}
                    {ifp 'commission.agent.delete'}<li><a data-toggle='ajaxRemove' href="{php echo webUrl('commission/agent/delete',array('id' => $row['id']));}" title="删除" data-confirm="确定要删除该分销商吗？"><i class='fa fa-remove'></i> 删除分销商</a></li>{/if}

                    <li class='divider'></li>
                    {ifp 'order'}<li><a  href="{php echo webUrl('order/list', array('searchfield'=>'member', 'keyword'=>$row['nickname']))}" title='会员订单'  target='_blank'><i class='fa fa-list'></i> 会员订单</a></li>{/if}
                    {ifp 'finance.recharge.credit1'}<li><a data-toggle="ajaxModal" href="{php echo webUrl('finance/recharge', array('type'=>'credit1','id'=>$row['id']))}" title='充值积分'><i class='fa fa-credit-card'></i> 充值积分</a></li>{/if}
                    {ifp 'finance.recharge.credit2'}<li><a data-toggle="ajaxModal" href="{php echo webUrl('finance/recharge', array('type'=>'credit2','id'=>$row['id']))}" title='充值余额'><i class='fa fa-money'></i> 充值余额 </a></li>{/if}
                    {ifp 'member.list.delete'}<li><a  data-toggle='ajaxRemove'  href="{php echo webUrl('member/list/delete',array('id' => $row['id']));}" title='删除会员' data-confirm="确定要删除该会员吗？"><i class='fa fa-remove'></i> 删除会员</a></li>{/if}

                </ul>
            </div>


        </td>
    </tr>
    {/loop}
    </tbody>
</table>
{$pager}

{else}
<div class='panel panel-default'>
    <div class='panel-body' style='text-align: center;padding:30px;'>
        暂时没有任何分销商!
    </div>
</div>
{/if}
<script language="javascript">



    require(['bootstrap'],function(){
        $("[rel=pop]").popover({
            trigger:'manual',
            placement : 'left',
            title : $(this).data('title'),
            html: 'true',
            content : $(this).data('content'),
            animation: false
        }).on("mouseenter", function () {
            var _this = this;
            $(this).popover("show");
            $(this).siblings(".popover").on("mouseleave", function () {
                $(_this).popover('hide');
            });
        }).on("mouseleave", function () {
            var _this = this;
            setTimeout(function () {
                if (!$(".popover:hover").length) {
                    $(_this).popover("hide")
                }
            }, 100);
        });


    });


</script>

{template '_footer'}
<!--913702023503242914-->